import { FormItemRule } from "naive-ui";
import { useUserStore } from '@/store/modules/user'
import { storeToRefs } from "pinia";
const userStore = useUserStore()
const { info } = storeToRefs(userStore)
/**
 * 增加表单配置
 */
export const addFormConfig: Record<string, any> = {
    cols: 24,
    xGap: 24,
    labelPlacement: 'left',
    labelWidth: 120,
    formItems: [
        {
            field: "role_id",
            labelName: "角色id",
            labelStyle: "fontSize:14px;",
            type: "Input",
            inputType: "text",
            inputWidth: "180px",
            placeholder: "请填写角色id",
            span: 12
        },
        {
            field: "role_name",
            labelName: "角色名称",
            labelStyle: "fontSize:14px;",
            type: "Input",
            inputType: "text",
            inputWidth: "180px",
            placeholder: "请填写角色名称",
            span: 12
        },
        {
            field: "des",
            labelName: "角色描述",
            labelStyle: "fontSize:14px;",
            type: "TextArea",
            inputType: "textarea",
            placeholder: '请输入个性签名',
            autosize: {
                minRows: 3,
                maxRows: 5,
            },
            span: 24
        },


    ],
    rules: {
        role_id: {
            required: true,
            trigger: ["input"],
            message: "请填写角色id(数字)",
            validator(rule: FormItemRule, value: string) {
                if (value.length === 0 && typeof parseInt(value) === 'number') {
                    return new Error("未填写角色id");
                }
                return true;
            },
        },
        role_name: {
            required: true,
            trigger: ["input"],
            message: "请填写角色名称",
            validator(rule: FormItemRule, value: string) {
                if (value.length === 0) {
                    return new Error("未填写角色名称");
                }
                return true;
            },
        },

    },
};


/**
 * 修改表单配置
 */
export const updateFormConfig: Record<string, any> = {
    cols: 24,
    xGap: 24,
    labelPlacement: 'left',
    labelWidth: 120,
    formItems: [
        {
            field: "role_id",
            labelName: "角色id",
            labelStyle: "fontSize:14px;",
            type: "Input",
            inputType: "text",
            inputWidth: "180px",
            placeholder: "请填写角色id",
            disabled:true,
            span: 12
        },
        {
            field: "role_name",
            labelName: "角色名称",
            labelStyle: "fontSize:14px;",
            type: "Input",
            inputType: "text",
            inputWidth: "180px",
            placeholder: "请填写角色名称",
            span: 12
        },
        {
            field: "des",
            labelName: "角色描述",
            labelStyle: "fontSize:14px;",
            type: "TextArea",
            inputType: "textarea",
            placeholder: '请输入个性签名',
            autosize: {
                minRows: 3,
                maxRows: 5,
            },
            span: 24
        },


    ],
    rules: {
        role_id: {
            required: true,
            trigger: ["input"],
            message: "请填写角色id(数字)",
            validator(rule: FormItemRule, value: string) {
                if (value.length === 0 && typeof parseInt(value) === 'number') {
                    return new Error("未填写角色id");
                }
                return true;
            },
        },
        role_name: {
            required: true,
            trigger: ["input"],
            message: "请填写角色名称",
            validator(rule: FormItemRule, value: string) {
                if (value.length === 0) {
                    return new Error("未填写角色名称");
                }
                return true;
            },
        },

    },
};


/**
 * 分配角色表单配置
 */
 export const authFormConfig: Record<string, any> = {
    cols: 24,
    xGap: 24,
    labelPlacement: 'left',
    labelWidth: 120,
    formItems: [
        {
            field: "role_id",
            labelName: "角色id",
            labelStyle: "fontSize:14px;",
            type: "Input",
            inputType: "text",
            inputWidth: "180px",
            disabled:true,
            span: 24
        },
        {
            field: "auth",
            labelName: "权限名称",
            labelStyle: "fontSize:14px;",
            type: "CheckBox",
            span: 24
        },
       

    ],
    rules: {
        
    },
};


